package 多线程.三个线程实现顺序打印;

/**
 * 方式一：join()方法
 */
public class Test1{
    public static void main(String[] args) {
        Thread t1 = new Thread(){
            @Override
            public void run() {
                System.out.print("first ");
            }
        };
        Thread t2 = new Thread(){
            @Override
            public void run() {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.print("second ");
            }
        };
        Thread t3 = new Thread(){
            @Override
            public void run() {
                try {
                    t1.join();
                    t2.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("third");

            }
        };
        t1.start();
        t2.start();
        t3.start();
    }
}
